package com.example.demo.Service;

import com.example.demo.Mappers.GetRecipeListMapper;
import com.example.demo.beans.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**查询待缴费处方
 * Created by Administrator on 2018-05-08.
 */
@Service("GetRecipeListService")
public class GetRecipeListService {
    @Autowired
  private   GetRecipeListMapper mapper;
    @Transactional(readOnly = true)
    public GetRecipeListResponse getRecipeResponse(GetRecipeListRequest1 request){
        /**获取处方个数**/
        List<GetRecipeListItem3> item3s=new ArrayList<>();
        item3s =mapper.selectRecipe1(request.getRegID());
//        System.out.print(item3s.get(0).getDoctName());
        List<GetRecipeListItem2> item2s=new ArrayList<>();

        for (int i=0;i<item3s.size();i++){
            List<GetRecipeListtem1> listtem1s=new ArrayList<>();
            listtem1s=mapper.selectdetailRecipe1(item3s.get(i).getRecipeID(),item3s.get(i).getYzlx());
            GetRecipeListItem2 item2=new GetRecipeListItem2(listtem1s,item3s.get(i).getDeptID(),
                    item3s.get(i).getDeptName(),item3s.get(i).getDoctName(),item3s.get(i).getRecipeID(),item3s.get(i).getRecipeName(),item3s.get(i).getRecipeType(),item3s.get(i).getRecipeAmount(),item3s.get(i).getExecDept(),item3s.get(i).getExecLocation(),item3s.get(i).getRecipeDate(),item3s.get(i).getExecDate(),item3s.get(i).getNote());
            item2s.add(item2);
        }


        GetRecipeListResponse response=new GetRecipeListResponse();
        response.setResultCode("0");
        response.setRegID(request.getRegID());
        response.setResultMsg("交易成功");
        response.setRecipes(item2s);
        return  response;
    }
}
